from PySide6.QtCore import QDateTime
from Devices.Chiot.BsDevs.ComDev.ComDevParser import ComDevParser

class HumitureParser(ComDevParser):
    def ParseHeartbeat(msgValue, fullStatus):
        if not "stateValue" in msgValue:
            return True
        stateValue = msgValue["stateValue"]

        ret, value = HumitureParser.GetIntProperty(stateValue, "temperature", "temperature")
        if ret:
            fullStatus.temperature = value

        ret, value = HumitureParser.GetIntProperty(stateValue, "humidity", "humidity")
        if ret:
            fullStatus.humidity = value

        ret, value = HumitureParser.GetIntProperty(stateValue, "checkStatus", "status")
        if ret:
            fullStatus.checkStatus = value

        ret, value = HumitureParser.GetIntProperty(stateValue, "checkStatusTime", "timestamp")
        if ret:
            fullStatus.checkStatusTime = value
        return True
